<!-- 成员列表 -->
<template>
    <div class="member-wrap">
        <div class="search-wrap">
            <el-input class="srt-el-input-item search-input" v-model="keyWord" placeholder="请输入姓名、学校/单位、学段学科" :suffix-icon="Search"></el-input>
            <el-button class="srt-el-button srt-el-button--primary srt-el-button-h32" type="primary" @click="search">查询</el-button>
            <el-button class="srt-el-button srt-el-button--cancel srt-el-button-h32" @click="reset">重置</el-button>
        </div>
        <MemberAuth
            v-if="isAdmin || isCreater"
            ref="memberAuthRef"
            :is-creater="isCreater"
            :key-word="keyWord"/>
        <MemberCustom 
            v-else
            ref="memberCustomRef"
            :key-word="keyWord"/>
    </div>
</template>

<script setup>
import MemberAuth from './../part/member-auth.vue';
import MemberCustom from './../part/member-custom.vue';
import { Search } from '@element-plus/icons-vue';
import { ref, reactive, watch, onMounted, nextTick } from 'vue';

const props = defineProps({
    isCreater: { // 是否是专题创建人
        type: Boolean,
        default: false
    },
    isAdmin: { // 是否是专题管理员
        type: Boolean,
        default: false
    },
});

const memberAuthRef = ref(null);

const memberCustomRef = ref(null);

// 关键字搜素
const keyWord = ref('');


// 根据条件搜索
function search () {
    refreshData();
}

// 重置
function reset () {
    keyWord.value = '';
    nextTick(() => {
        refreshData();
    })
}

function refreshData () {
    memberAuthRef.value && memberAuthRef.value.refreshData();
    memberCustomRef.value && memberCustomRef.value.refreshData();
}

defineExpose({
    refreshData
})
</script>

<style lang="scss" scope>
.member-wrap {
    padding: 20px;
    .search-wrap {
        display: flex;
        align-items: center;
        margin-bottom: 20px;
        .search-input {
            width: 300px;
            margin-right: 10px;
        }
    }
}
</style>